Attempts to add the specified item to any one of the specified
BlockingCollection<(Of <(T>)>) instances.
A
OperationCanceledException is thrown if the
CancellationToken is
canceled.
Namespace:
System.Collections.Concurrent
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Shared Function TryAddToAny ( _
collections As BlockingCollection(Of T)(), _
item As T, _
millisecondsTimeout As Integer, _
cancellationToken As CancellationToken _
) As Integer |
Return Value
The index of the collection in the
collections
array to which the item was added, or -1 if the item could not be added.
Exceptions
Exception | Condition |
---|
System..::.OperationCanceledException | If the CancellationToken is canceled. |
System..::.ArgumentNullException | The collections argument is
null. |
System..::.ArgumentException | The collections argument is
a 0-length array or contains a null element, or at least one of collections has been
marked as complete for adding. |
System..::.ObjectDisposedException | At least one of the BlockingCollection<(Of <(T>)>) instances has been disposed. |
System..::.ArgumentOutOfRangeException | millisecondsTimeout is a
negative number other than -1, which represents an infinite time-out. |
System..::.InvalidOperationException | At least one underlying collection didn't accept the item. |
System..::.ArgumentOutOfRangeException | The count of collections is greater than the maximum size of
62 for STA and 63 for MTA. |
See Also